import 'package:blog/app/package_info.dart';
import 'package:blog/base/get/getx_controller_inject.dart';
import 'package:blog/model/request_register.dart';
import 'package:blog/ui/dialog/dialog_share_appliction.dart';
import 'package:blog/util/constant.dart';
import 'package:blog/util/save/sp_util.dart';
import 'package:blog/util/toast_util.dart';
import 'package:blog/util/web_util.dart';
import 'package:get/get.dart';


/// @class : AboutController
/// @date : 2021/08/25
/// @name : CTGU_LLZ(404name)
/// @description :关于我们 控制器层
class AboutController extends BaseGetController {

  ///用户信息
  late UserEntity userInfo;

  @override
  void onInit() {
    super.onInit();
    var info = SpUtil.getUserInfo();
    if(info != null){
      userInfo = info;
      update();
    }
  }

  void checkVersion(){

      request.websiteInfo(success: (data,over) {
        ///添加自定义的积分排行榜图片
        SpUtil.putWebsiteInfo(data);
        print("拉取网站信息");
        var version = SpUtil.getWebsiteInfo()!.websiteConfig.version == null?PackageInfo.versionCode:SpUtil.getWebsiteInfo()!.websiteConfig.version;
        print(PackageInfo.versionCode + "<====>" + version);
        if(PackageInfo.versionCode == version){
          ToastUtils.show("当前已是最新版本");
        }else{
          var name = SpUtil.getWebsiteInfo()!.websiteConfig.websiteName == null?PackageInfo.versionName:SpUtil.getWebsiteInfo()!.websiteConfig.websiteName;

          var des = SpUtil.getWebsiteInfo()!.websiteConfig.versionDesc == null?"暂无介绍":SpUtil.getWebsiteInfo()!.websiteConfig.versionDesc;
          ToastUtils.show("有新版本发布了");
          Get.dialog(ShareDialog(url : Constant.downloadUrl,
              title:  name + version,
              des: des));
        };
      });


  }


}
